package com.api.cube.service;

import com.api.browser.bean.BrowserBean;
import com.api.browser.bean.BrowserTabBean;
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.BrowserInitUtil;
import com.api.cube.bean.RightMenu;
import com.api.cube.util.CubeCipherUitl;
import com.api.doc.detail.util.DocDownloadCheckUtil;
import com.api.formmode.cache.CustomSearchComInfo;
import com.api.formmode.cache.ModeComInfo;
import com.api.formmode.cache.ModeFormFieldEncryptComInfo;
import com.engine.common.util.ParamUtil;
import com.engine.cube.biz.BrowserHelper;
import com.engine.cube.biz.CardFormHelper;
import com.engine.cube.biz.DataHelper;
import com.engine.cube.biz.ShardingActionHelper;
import com.engine.cube.biz.ShardingHelper;
import com.engine.cube.util.SaveConditionUtil;
import com.engine.hrm.biz.HrmClassifiedProtectionBiz;
import com.engine.workflow.biz.wfPathAdvanceSet.BrowserDataDefinitionBiz;
import com.weaver.formmodel.util.DateHelper;
import com.weaver.formmodel.util.StringHelper;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.dateformat.DateTransformer;
import weaver.dateformat.UnifiedConversionInterface;
import weaver.docs.category.SecCategoryComInfo;
import weaver.formmode.data.ModeDataIDUpdateSingle;
import weaver.formmode.data.ModeDataIdUpdate;
import weaver.formmode.data.ModeDataInterface;
import weaver.formmode.data.ModeDataManager;
import weaver.formmode.search.CustomSearchBatchEditUtil;
import weaver.formmode.search.FormModeRightInfo;
import weaver.formmode.search.FormModeTransMethod;
import weaver.formmode.service.CustomSearchService;
import weaver.formmode.service.FormInfoService;
import weaver.formmode.service.RepeatVerifyService;
import weaver.formmode.setup.ExpandBaseRightInfo;
import weaver.formmode.setup.ModeRightInfo;
import weaver.formmode.view.ModeViewLog;
import weaver.formmode.virtualform.UUIDPKVFormDataSave;
import weaver.formmode.virtualform.VirtualFormHandler;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CubeSearchEditService extends BaseBean {

	private FormModeRightInfo formModeRightInfo=new FormModeRightInfo();
	private static final ExecutorService actionThreadPool = Executors.newFixedThreadPool(5);
	private ModeFormFieldEncryptComInfo modeFormFieldEncryptComInfo=new ModeFormFieldEncryptComInfo();
	private Map<String,List<String>> fieldDependShip = new HashMap<String,List<String>>();	//字段依赖关系
	/***
	 * 批量修改查询字段显示列字段类型
	 * @param request
	 * @param response
	 * @return
	 */
	public Map<String, Object> getSearchColumnInfo(HttpServletRequest request,
												   HttpServletResponse response) {
		int customid = Util.getIntValue(request.getParameter("customid"));
		CustomSearchComInfo customSearchComInfo = new CustomSearchComInfo();
		String modeId = Util.null2String(customSearchComInfo.getModeId(customid+""));
		int formid=Util.getIntValue(Util.null2String(customSearchComInfo.getFormId(customid+"")),0);
		User user = HrmUserVarify.getUser(request,response);
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> dataList=new ArrayList<Map<String,Object>>();
		RecordSet rs = new RecordSet();
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		Map<String, Object> optionsMap=new HashMap<String, Object>();
		Map<String, Object> browserMap=new HashMap<String, Object>();
		Map<String,Object> uploadDataMap=new HashMap<String,Object>();
		List<BrowserTabBean> tabs = new ArrayList<BrowserTabBean>();
		if(Util.getIntValue(modeId)>0){
			//加载表单浏览数据定义取字段值的设置
			this.fieldDependShip.putAll(BrowserDataDefinitionBiz.getRelateFields(-1*Util.getIntValue(modeId),user));
			CardFormHelper.fieldDependShip = fieldDependShip;
		}
		Boolean isllk = false;

		String sql = "select a.fieldid, " +
				"a.colwidth, " +
				"a.shownamelabel, " +
				"a.editable, " +
				"b.qfws, " +
				"b.fieldlabel, " +
				"b.fieldhtmltype, " +
				"b.type, " +
				"b.viewtype, " +
				"b.detailtable, " +
				"b.fieldname, " +
				"b.fielddbtype, " +
				"b.billid, " +
				"b.textheight, " +
				"a.showorder  " +
				"from " +
				"mode_CustomDspField a, " +
				"workflow_billfield b where " +
				"a.fieldid = b.id " +
				"and " +
				"a.customid = ? " +
				"and a.isshow = '1' " +
				"union all  " +
				"select " +
				" a.fieldid, " +
				" a.colwidth, " +
				" a.shownamelabel, " +
				" a.editable, " +
				" null as qfws, " +
				" null as fieldlabel, " +
				" null as fieldhtmltype, " +
				" null as type, " +
				" 0 as viewtype, " +
				" '' as detailtable, " +
				" '' as fieldname, " +
				" '' as fielddbtype, " +
				" null as billid, " +
				" null as textheight, " +
				"  a.showorder " +
				" from " +
				" Mode_CustomDspField a " +
				"where " +
				" a.customid = ? " +
				" and a.isshow = '1' " +
				" and a.fieldid<0 " +
				"order by " +
				" showorder asc, " +
				" viewtype, " +
				" fieldid asc ";

		rs.executeQuery(sql, customid,customid);
		int editFieldCount=0;
		String categoryType ="";
		String mainCategory ="";
		String subCategory ="";
		String secCategory ="";
		String selectCategory ="";
		int istagset =0;
		int maxUploadSize=0;
		String tempFileformat="";
		rs3.executeQuery("select istagset from modeinfo where id=?",modeId);
		while(rs3.next()){
			istagset=rs3.getInt("istagset");
		}
		while(rs.next()){
			String fieldid=rs.getString("fieldid");
			if("-6".equals(fieldid)||("-4".equals(fieldid)&&istagset==0)){//操作列不展示
				continue;
			}
			String fieldhtmltype=rs.getString("fieldhtmltype");
			String fieldtype=rs.getString("type");
			String fielddbtype=rs.getString("fielddbtype");
			String billid=rs.getString("billid");
			String fieldname=rs.getString("fieldname");
			int qfws=Util.getIntValue(Util.null2String(rs.getString("qfws")), 0);
			int textheight=Util.getIntValue(Util.null2String(rs.getString("textheight")), 0);
			String viewtype = rs.getString("viewtype");

			if("-9".equals(fieldid)){//密级字段
				fieldhtmltype="5";
				fieldtype="1";
				fielddbtype="integer";

			}
			//其他相关信息
			if("1".equals(fieldhtmltype)) {
				if ("3".equals(fieldtype)) {
					qfws =  fielddbtype.indexOf(",") > -1 ? Util.getIntValue(fielddbtype.substring(fielddbtype.indexOf(",") + 1, fielddbtype.indexOf(")"))) : 2;
				}  else if("4".equals(fieldtype)) {
					qfws=2;
				}
			}else if("5".equals(fieldhtmltype)) {
				JSONArray options = new JSONArray();
				if("-9".equals(fieldid)){
					options.add(BrowserHelper.constructMap("key", "", "showname", "", "selected", false));
					HrmClassifiedProtectionBiz hrmClassifiedProtectionBiz = new HrmClassifiedProtectionBiz();
					List<SearchConditionOption> comOptions = hrmClassifiedProtectionBiz.getResourceOptionListByUser(user);
					if (null != comOptions && comOptions.size() > 0) {
						for (SearchConditionOption searchConditionOptioninner : comOptions) {
							String selectvalue = searchConditionOptioninner.getKey();
							String selectname = searchConditionOptioninner.getShowname();
							options.add(BrowserHelper.constructMap("key", selectvalue
									,"showname",selectname,"selected",false,"docCategory", "","maxUploadSize",5));
						}
					}
				}else{
					rs1.executeQuery("select id,selectvalue,selectname,docCategory from workflow_selectitem where fieldid = ? and cancel!='1' order by listorder ,selectvalue", fieldid);

					options.add(BrowserHelper.constructMap("key", "", "showname", "", "selected", false));
					while(rs1.next()) {
						String docCategory= rs1.getString("docCategory");
						int maxUploadSizeOption = 5;
						if(!StringHelper.isEmpty(docCategory)) {
							String [] category = Util.splitString(docCategory, ",");
							maxUploadSizeOption = Util.getIntValue(new SecCategoryComInfo().getMaxUploadFileSize(category[category.length-1]),5);
							maxUploadSizeOption = maxUploadSizeOption==0?5:maxUploadSizeOption;
						}
						options.add(BrowserHelper.constructMap("key", rs1.getString("selectvalue")
								,"showname", rs1.getString("selectname"),"selected",false,"docCategory", docCategory,"maxUploadSize",maxUploadSizeOption));
					}
				}

				optionsMap.put(fieldid, options);
			} else if("3".equals(fieldhtmltype)) {
				BrowserBean browserProps = null;
				if("161".equals(fieldtype) || "162".equals(fieldtype)) {
					browserProps = new BrowserBean(fieldtype);
					new BrowserInitUtil().initCustomizeBrow(browserProps,fielddbtype, Util.getIntValue(fieldtype) , user.getUID());
					browserProps.getDataParams().put("formmodefieldid",fieldid);
					browserProps.getConditionDataParams().put("formmodefieldid", fieldid);
					browserProps.getCompleteParams().put("formmodefieldid", fieldid);
					isllk = true;
				} else if("256".equals(fieldtype) || "257".equals(fieldtype)) {
					browserProps = new BrowserBean(fieldtype);
					browserProps.getDataParams().put("cube_treeid", fielddbtype);
					browserProps.getCompleteParams().put("cube_treeid", fielddbtype);
					new BrowserInitUtil().initBrowser(browserProps,user.getLanguage());
					isllk = true;
				}else if("4".equals(fieldtype) || "57".equals(fieldtype)|| "164".equals(fieldtype)|| "169".equals(fieldtype)|| "167".equals(fieldtype)|| "194".equals(fieldtype)|| "168".equals(fieldtype)|| "170".equals(fieldtype)){
					browserProps = new BrowserBean(fieldtype);
					Map<String,Object> map = new HashMap<>();
					map.put("fromModule","model");
					new BrowserInitUtil().initBrowser(browserProps,user.getLanguage());
					browserProps.setDataParams(map);
					browserProps.setCompleteParams(map);
				} else {
					browserProps = new BrowserBean(fieldtype);
					new BrowserInitUtil().initBrowser(browserProps,user.getLanguage());
				}
				if("9".equals(fieldtype)||"37".equals(fieldtype)){
					browserProps.setLinkUrl("/spa/document/index.jsp?id=");
				}else if("142".equals(fieldtype)){
					browserProps.setLinkUrl("/spa/odoc/static/index.html#/main/offical/recPostUnit?receiveUnitId=");
				}

				browserProps.getDataParams().put("isFromMode","1");
				browserProps.getDataParams().put("modeId",modeId);
				browserProps.getDataParams().put("fieldid",fieldid);
				browserProps.getDataParams().put("isFromMode","1");
				browserProps.getDataParams().put("isbill",1);
				browserProps.getDataParams().put("viewtype",viewtype);
				browserProps.getConditionDataParams().put("isFromMode","1");
				browserProps.getConditionDataParams().put("modeId",modeId);
				browserProps.getConditionDataParams().put("fieldid",fieldid);
				browserProps.getConditionDataParams().put("isFromMode","1");
				browserProps.getConditionDataParams().put("isbill",1);
				browserProps.getConditionDataParams().put("viewtype",viewtype);
				browserProps.getCompleteParams().put("isFromMode","1");
				browserProps.getCompleteParams().put("modeId",modeId);
				browserProps.getCompleteParams().put("fieldid",fieldid);
				browserProps.getCompleteParams().put("isFromMode","1");
				browserProps.getCompleteParams().put("isbill",1);
				browserProps.getCompleteParams().put("viewtype",viewtype);
				if(Util.getIntValue(modeId)>0){
					tabs = BrowserDataDefinitionBiz.getBrowserDataDefinitionTabs(Util.getIntValue(fieldtype),-1*Util.getIntValue(modeId),Util.getIntValue(fieldid),user);
					if(tabs!=null&&tabs.size()>0){
						browserProps.setTabs(tabs);
					}
					//浏览数据定义条件 模块字段 批量修改,批量新增不支持
//					List<String> relateFieldid = fieldDependShip.get(fieldid+"");
//					if(relateFieldid != null && relateFieldid.size() > 0)
//						browserProps.setRelateFieldid(relateFieldid);
				}
				browserMap.put(fieldid, browserProps);
			}else if("6".equals(fieldhtmltype)){//查询列表-批量修改-支持附件上传字段   QC:516909
				//获取文档上传目录 和 格式限制
				/**
				 * categoryType  0:固定目录   1：选择目录    9：默认设置
				 * fileFormat   文档限制格式
				 **/
				//先获取默认信息
				ModeComInfo modeComInfo = new ModeComInfo();
				categoryType = Util.null2String(modeComInfo.getCategoryType(modeId));
				if("1".equals(categoryType)) {
					selectCategory = Util.null2String(modeComInfo.getSelectCategory(modeId));
					result.put("selectCategory",selectCategory);
				} else {
					mainCategory = Util.null2String(modeComInfo.getMainCategory(modeId));
					subCategory = Util.null2String(modeComInfo.getSubCategory(modeId));
					secCategory = Util.null2String(modeComInfo.getSecCategory(modeId));
					//判断目录是否有效
					String categoryname =Util.null2String(new SecCategoryComInfo().getSecCategoryname(secCategory));
					if("".equals(categoryname)){
						secCategory="0";
					}
					maxUploadSize = Util.getIntValue(new SecCategoryComInfo().getMaxUploadFileSize(secCategory),0);
					maxUploadSize = maxUploadSize==0?5:maxUploadSize;
				}
				rs2.executeQuery("select * from mode_fileuploadset where fieldid = ?  and  modeid= ?",fieldid,modeId);
				if(rs2.next()){
					String fileFormatType = Util.null2String(rs2.getString("fileFormatType"));
					String fileFormat = Util.null2String(rs2.getString("fileFormat"));
					categoryType = Util.null2String(rs2.getString("categorytype"));
					int limitValue = Util.getIntValue(rs2.getString("limitValue"),5);
					if("1".equals(categoryType) ||("9".equals(categoryType)&& "1".equals(Util.null2String(modeComInfo.getCategoryType(modeId))))) {//选择目录
						selectCategory = Util.null2String(modeComInfo.getSelectCategory(modeId));
						categoryType="1";
						//result.put("selectCategory",selectCategory);
						//result.put("selectCategory", BrowserHelper.constructMap("selectCategory",selectCategory,"categoryType",categoryType));
					} else if("0".equals(categoryType)){//固定目录上传
						mainCategory = Util.null2String(rs2.getString("maincategory"));
						subCategory = Util.null2String(rs2.getString("subCategory"));
						secCategory = Util.null2String(rs2.getString("secCategory"));
						maxUploadSize = Util.getIntValue(new SecCategoryComInfo().getMaxUploadFileSize(secCategory),0);
						maxUploadSize = maxUploadSize==0?5:maxUploadSize;
					}
					if(!"0".equals(fileFormatType) && !"".equals(fileFormatType)){
						result.put("fileFormatType",fileFormatType);
						result.put("fileFormat",fileFormat);
					}else if("1".equals(fieldtype)){//文档
						rs1.executeQuery("select fileFormat from modeinfo where id = " + modeId);
						if(rs1.next()){
							fileFormat = Util.null2String(rs1.getString("fileFormat"));
							if(!"0".equals(fileFormat) && !"".equals(fileFormat)){
								result.put("fileFormatType","1");
								result.put("fileFormat",fileFormat);
							}else{
								result.put("fileFormat","0");
							}
						}else{
							result.put("fileFormat","0");
						}
					}else{
						result.put("fileFormat","0");
					}

					tempFileformat=result.get("fileFormat").toString();
					result.put("limitValue",limitValue == 0? 5 : limitValue );
				}
			}

			Map<String, Object> map=new HashMap<String, Object>();

			if("6".equals(fieldhtmltype)){
				map.put("uploadMap", BrowserHelper.constructMap("mainCategory", mainCategory
						,"subCategory",subCategory,"secCategory",secCategory,"maxUploadSize",maxUploadSize,"categoryType",categoryType,"fileFormat", tempFileformat,"selectCategory",selectCategory));
			}
			map.put("fieldid", fieldid);
			map.put("colwidth", rs.getString("colwidth"));
			map.put("fieldhtmltype", fieldhtmltype);
			map.put("type", fieldtype);
			map.put("fielddbtype", fielddbtype);
			String editable=Util.null2String(rs.getString("editable"));
			if(editable.equals("1")){
				editFieldCount++;
			}
			map.put("editable", editable);
			map.put("viewtype", rs.getString("viewtype"));
			map.put("detailtable", rs.getString("detailtable"));
			if(Util.null2String(rs.getString("viewtype")).equals("1")){
				map.put("fieldname", "d_"+rs.getString("fieldname"));
			}else{
				map.put("fieldname", rs.getString("fieldname"));
			}
			if("3".equals(fieldhtmltype)){
				map.put("sqlNeedFieldKey", CardFormHelper.getSqlFiledKey(formid,Util.getIntValue(modeId), fieldtype, fieldid));
			}
			map.put("qfws", qfws);
			map.put("textheight", textheight);
			int shownamelabel=Util.getIntValue(Util.null2String(rs.getString("shownamelabel")),0);
			int fieldlabel=Util.getIntValue(Util.null2String(rs.getString("fieldlabel")),0);
			if(shownamelabel==0){
				map.put("fieldlabel", SystemEnv.getHtmlLabelName(fieldlabel, user.getLanguage()));
			}else{
				map.put("fieldlabel", SystemEnv.getHtmlLabelName(shownamelabel, user.getLanguage()));
			}
			dataList.add(map);

		}
		// 查询右键菜单
		String customId = Util.null2String(request.getParameter("customid"));
		RecordSet rsMenu = new RecordSet();
		rsMenu.executeQuery("select expendname from mode_pageexpand where modeid = ? and issystemflag=99",modeId);
		String expendname = "";
		while (rsMenu.next()){
			expendname = Util.null2String(rsMenu.getString("expendname"));
		}
		if(Util.isEnableMultiLang()){
			expendname = Util.formatMultiLang(expendname.trim(),user.getLanguage()+"");
		}
		if(StringHelper.isEmpty(expendname)){
			expendname = SystemEnv.getHtmlLabelName(385215, user.getLanguage());
		}
		// 批量新增按钮
		RightMenu bathEditSaveQuickButton = new RightMenu("doBatchStorage", expendname, "icon-coms-Preservation", "doBatchStorage").isQuickButton(true);

		result.put("bathEditSaveQuickButton",bathEditSaveQuickButton);
		result.put("dataList", dataList);
		result.put("optionsMap", optionsMap);
		result.put("browserMap", browserMap);
		result.put("editFieldCount",editFieldCount);
		return result;
	}

	//获取imgType下的相关字段信息
	public Map<String, Object> getTitleField(HttpServletRequest request,
											 HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();

		int customid = Util.getIntValue(Util.null2String(request.getParameter("customid")), 0);

		rs.executeQuery("select fieldid,istitle from Mode_Customdspfield where isshow = 1 and customid = ? order by isshow asc,showorder asc,fieldid asc",customid);
		while(rs.next()){
			if(!"0".equalsIgnoreCase(StringHelper.null2String(rs.getString("istitle")))){
				JSONObject jsonObject = new JSONObject();
				String fieldid = Util.null2String(rs.getString("fieldid"));
				if("-3".equals(fieldid)){
					jsonObject.put("fieldid", "-3");
					jsonObject.put("fieldname", "id");
					jsonObject.put("istitle", "1");
					result.put("titleField", jsonObject);
				}else{
					String fieldname = "";
					RecordSet rs1 =  new RecordSet();
					rs1.executeQuery("select fieldname,detailtable from workflow_billfield where id = ?",fieldid);
					if(rs1.next()){
						fieldname =Util.null2String(rs1.getString("fieldname"));
						if(!StringHelper.isEmpty(rs1.getString("detailtable"))){
							fieldname = "d_"+fieldname;
						}
						jsonObject.put("fieldid", fieldid);
						jsonObject.put("fieldname", fieldname);
						jsonObject.put("istitle", "1");
						result.put("titleField", jsonObject);
					}
				}
				break;
			}
		}

		rs.executeQuery("select a.datashowtype,a.datashowtypefilefield,a.datashowtypefileicon,a.formid,b.detailtable,b.fieldname from mode_customsearch a ,workflow_billfield b where a.datashowtypefilefield = b.id and a.id = ?",customid);
		if(rs.next()){
			JSONObject jsonObject = new JSONObject();
			String fieldname =Util.null2String(rs.getString("fieldname"));
			String datashowtypefilefield = Util.null2String(rs.getString("datashowtypefileicon"));
			if(!StringHelper.isEmpty(datashowtypefilefield)){
				DocDownloadCheckUtil docDownloadCheckUtil = new DocDownloadCheckUtil();
				datashowtypefilefield = docDownloadCheckUtil.checkPermission(datashowtypefilefield, null);
			}

			if(!StringHelper.isEmpty(rs.getString("detailtable"))){
				fieldname = "d_"+fieldname;
			}
			jsonObject.put("datashowtype", Util.getIntValue(rs.getString("datashowtype"),0));
			jsonObject.put("datashowtypefilefield", Util.null2String(rs.getString("datashowtypefilefield")));
			jsonObject.put("datashowtypefilefieldname", fieldname);
			jsonObject.put("datashowtypefileicon", datashowtypefilefield);
			result.put("datashowinfo", jsonObject);
			//result.put("imgfileidinfo", getImgFileid(rs.getString("datashowtypefilefield"),rs.getString("formid"),rs.getString("detailtable")));
		}
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("userid", user.getUID());
		jsonObject.put("usertype", user.getType());
		result.put("userInfo", jsonObject);

		return result;
	}

	public Map<String, Object> batchEditGetVerifyField(HttpServletRequest request,
													   HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();

		int customid = Util.getIntValue(Util.null2String(request.getParameter("customid")), 0);
		int modeid = 0;
		int formid = 0;
		String tablename = "";
		String detailtable = "";
		String detailkeyfield = "";
		String sql = "select a.modeid,a.formid,a.detailtable,b.tablename,b.detailkeyfield from mode_customsearch a left join workflow_bill b on a.formid=b.id where a.id="+customid;
		rs.executeSql(sql);
		if(rs.next()){
			modeid = Util.getIntValue(rs.getString("modeid"), 0);
			formid = Util.getIntValue(rs.getString("formid"), 0);
			tablename = Util.null2String(rs.getString("tablename"));
			detailtable=Util.null2String(rs.getString("detailtable"));
			detailkeyfield = Util.null2String(rs.getString("detailkeyfield"));
		}
		RepeatVerifyService rvService = new RepeatVerifyService();
		rvService.setUser(user);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("VerifyField", rvService.getVerifyField(formid));
		jsonObject.put("primaryKeyPluginName", "pluginNameid");
		jsonObject.put("detailPrimaryKeyPluginName", "pluginNamed_id");

		result.put("result", jsonObject);
		return result;
	}

	public Map<String, Object> batchEditVerifyData(HttpServletRequest request,
												   HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();

		RepeatVerifyService rvService = new RepeatVerifyService();
		String data = Util.null2String(request.getParameter("data"));
		int customid = Util.getIntValue(Util.null2String(request.getParameter("customid")), 0);
		int isBathAdd = Util.getIntValue(Util.null2String(request.getParameter("isBathAdd")), 0);
		int modeid = 0;
		int formid = 0;
		String tablename = "";
		String detailtable = "";
		String detailkeyfield = "";
		String sql = "select a.modeid,a.formid,a.detailtable,b.tablename,b.detailkeyfield from mode_customsearch a left join workflow_bill b on a.formid=b.id where a.id="+customid;
		rs.executeSql(sql);
		if(rs.next()){
			modeid = Util.getIntValue(rs.getString("modeid"), 0);
			formid = Util.getIntValue(rs.getString("formid"), 0);
			tablename = Util.null2String(rs.getString("tablename"));
			detailtable=Util.null2String(rs.getString("detailtable"));
			detailkeyfield = Util.null2String(rs.getString("detailkeyfield"));
		}
		data = data.replace("+", "%2B");

		JSONArray dataArr = JSONArray.fromObject(data);
		if(isBathAdd==1){
			rvService.setIsBathAdd(isBathAdd);
		}
		rvService.setUser(user);
		rvService.initVerifyField(formid);
		if(isBathAdd==0){
			rvService.completeVerifyFieldData(dataArr, tablename, detailtable);
		}
		JSONObject jsonObject = rvService.verifyDataSelf(dataArr, tablename, detailtable,"0");
		if(!jsonObject.getBoolean("verify")){
			jsonObject = rvService.verifyData(dataArr, tablename, detailtable);
		}

		Map<String, String> colorMap=new HashMap<String, String>();
		RecordSet rs1=new RecordSet();
		rs1.executeQuery("select id,color from modeformverify where formid ='"+formid+"'");
		while(rs1.next()){
			colorMap.put(rs1.getString("id"), rs1.getString("color"));
		}

		result.put("result", jsonObject);
		result.put("colorMap", colorMap);
		return result;
	}



	/***
	 * 批量修改保存接口
	 * @param request
	 * @param response
	 * @return
	 */
	public Map<String, Object> batchEditSave(HttpServletRequest request,
											 HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		List allModifyBillList = new ArrayList();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();
		int customid = Util.getIntValue(Util.null2String(request.getParameter("customid")), 0);
		String data = Util.null2String(request.getParameter("data"));
		String oldData = Util.null2String(request.getParameter("oldData"));
		JSONArray dataArray=JSONArray.fromObject(data);
		JSONArray oldDataArray=JSONArray.fromObject(oldData);
		String clientaddress = request.getRemoteAddr();
		boolean isBatchEdit = false;
		rs.executeSql("select * from mode_searchPageshareinfo where righttype=2 and pageid = " + customid);
		if(rs.next()){
			formModeRightInfo.setUser(user);
			isBatchEdit = formModeRightInfo.checkUserRight(Util.getIntValue(String.valueOf(customid)),2);
		}
		if(!isBatchEdit){
			result.put("errorCode", "-1");
			result.put("error", "no right");
			return result;
		}
		int modeid = 0;
		int formid = 0;
		String tablename = "";
		String detailtable = "";
		String detailkeyfield = "";
		String sql = "select a.modeid,a.formid,a.detailtable,b.tablename,b.detailkeyfield from mode_customsearch a left join workflow_bill b on a.formid=b.id where a.id="+customid;
		rs.executeSql(sql);
		if(rs.next()){
			modeid = Util.getIntValue(rs.getString("modeid"), 0);
			formid = Util.getIntValue(rs.getString("formid"), 0);
			tablename = Util.null2String(rs.getString("tablename"));
			detailtable=Util.null2String(rs.getString("detailtable"));
			detailkeyfield = Util.null2String(rs.getString("detailkeyfield"));
		}
		String sqlStr="select isdelfile from modeinfo where id=?";
		boolean isdelfile=false;
		rs.executeQuery(sqlStr, modeid);
		if (rs.next()) {
			isdelfile="1".equals(rs.getString("isdelfile"));
		}
		ModeComInfo modeinfo = new ModeComInfo();
		boolean isfrontmultlang="1".equals(modeinfo.getIsfrontmultlang(modeid+""));
		CustomSearchService customSearchService = new CustomSearchService();
		List<Map<String,Object>> editableFields = customSearchService.getEditableFieldsById(customid);
		Map<String,Object> editableFieldMap = new HashMap<String,Object>();
		for(int i=0;i<editableFields.size();i++){
			Map<String,Object> editableField = editableFields.get(i);
			String fieldId = Util.null2String(editableField.get("id"));
			editableFieldMap.put(fieldId, editableField);
		}
		StringBuffer batchEditMessage = new StringBuffer();
		CustomSearchBatchEditUtil customSearchBatchEditUtil  = new CustomSearchBatchEditUtil();
		Map<String,Object> needLogFieldsMap = customSearchBatchEditUtil.getNeedLogFields(formid);
		Map<String,Object> modeRightRelatedFieldsMap = new HashMap<String,Object>();

		// CHANGE START
		boolean isModeSharding = ShardingActionHelper.isModeSharding(modeid);
		// CHANGE END
		List<String> billList = new ArrayList<String>();
		List<Integer> modeList = new ArrayList<Integer>();
		List<String> formBizIdList = new ArrayList<>();
		for(int i=0;i<dataArray.size();i++){
			JSONObject dataObject = dataArray.getJSONObject(i);
			JSONObject oldDataObject = oldDataArray.getJSONObject(i);
			String updateMaintableSql = "";
			String updateDetailtableSql = "";
			boolean ismodifyneedlogfield = false;
			boolean ismodifyRelatedField = false;
			customSearchBatchEditUtil.resetNeedLogFields(needLogFieldsMap);
			String mainid = Util.null2o(dataObject.getString("randomFieldId"));
			// CHANGE START
			String suffix = "";
			String formBizId = mainid;
			String datasource = "";
			String primarykey = "id";
			if (isModeSharding) {
				mainid = ShardingActionHelper.extractBillId(formBizId);
				suffix = ShardingActionHelper.getShardingSuffix(formBizId);
				datasource = ShardingHelper.SHARDING_POOL_NAME;
				primarykey = ShardingHelper.KEY_FORM_BIZ_ID;
			}
			allModifyBillList.add(formBizId);
			String detailid =dataObject.has("randomFieldSubKeyd_id")?Util.null2String(dataObject.getString("randomFieldSubKeyd_id")):"";
			rs.executeSql("select formmodeid from " + tablename + " where "+ primarykey +" = " + "'" + formBizId + "'", datasource);
			// CHANGE END
			if(!rs.next())continue;
			if(modeid==0){
				modeid = Util.getIntValue(rs.getString("formmodeid"), 0);
			}
			if(modeid==0)continue;
			Map<String,Object> rightRelatedFieldsMap = null;
			if(modeRightRelatedFieldsMap.containsKey(String.valueOf(modeid))){
				rightRelatedFieldsMap = (Map<String,Object>)modeRightRelatedFieldsMap.get(String.valueOf(modeid));
			}else{
				rightRelatedFieldsMap = customSearchBatchEditUtil.getRightRelatedFields(modeid);
				modeRightRelatedFieldsMap.put(String.valueOf(modeid), rightRelatedFieldsMap);
			}

			Map<String,Object> modifyRightRelatedFieldsMap = new HashMap<String,Object>();

			// CHANGE START
			List<String> suffixList = new ArrayList<>();
			if (isModeSharding) {
				suffixList = ShardingActionHelper.getAllShardingSuffix(modeid);
			} else {
				suffixList.add("");
			}
			// CHANGE END
			Vector mainV = new Vector();
			Vector detailV = new Vector();
			Iterator<String> it = dataObject.keys();
			while(it.hasNext()){
				String key=it.next();//key即为修改的字段id
				if("randomFieldId".equals(key)||"randomFieldSubKeyd_id".equals(key))continue;
				String value=Util.null2String(dataObject.getString(key));
				String oldValue=Util.null2String(oldDataObject.getString(key));
				if(!editableFieldMap.containsKey(key)) continue;
				Map<String,Object> editableField = (Map<String,Object>)editableFieldMap.get(key);
				String fieldId = Util.null2String(editableField.get("id"));
				String fieldName = Util.null2String(editableField.get("fieldname"));
				String fieldHtmlType = Util.null2String(editableField.get("fieldhtmltype"));
				String fieldType = Util.null2String(editableField.get("type"));
				String fieldDbType = Util.null2String(editableField.get("fielddbtype"));
				int viewtype = Util.getIntValue(Util.null2String(editableField.get("viewtype")), 0);
				Object realFieldValue = customSearchBatchEditUtil.AnalyzeStorageValue(value, fieldHtmlType, fieldType, fieldDbType);
				String isencrypt= modeFormFieldEncryptComInfo.getIsencrypt(fieldId);
				if("1".equals(isencrypt)){
					realFieldValue=CubeCipherUitl.encrypt(Util.null2String(realFieldValue));
				}

				boolean isEqualVal = customSearchBatchEditUtil.judgeEqualFieldValue(fieldHtmlType,fieldType,oldValue, realFieldValue,value);
				if(isEqualVal) continue;
				//记录日志字段
				if(needLogFieldsMap.containsKey(fieldId)){
					JSONObject jsonObject = (JSONObject)needLogFieldsMap.get(fieldId);
					jsonObject.put("nfieldvalue", value);
					jsonObject.put("ofieldvalue", oldValue);
					ismodifyneedlogfield = true;
				}

				//判断权限关联字段值是否改变
				if(rightRelatedFieldsMap.containsKey(fieldId)){
					modifyRightRelatedFieldsMap.put(fieldId, rightRelatedFieldsMap.get(fieldId));
					ismodifyRelatedField = true;
				}
				DataHelper dataHelper = new DataHelper(user);
				String temptablename=tablename;
				if(viewtype==0){
					updateMaintableSql += ","+fieldName+"=?";
					mainV.addElement(realFieldValue);
					if(isdelfile&&fieldHtmlType.equals("6")){
						new DataHelper(user).deleteDocFile(value, modeid, fieldName, tablename, mainid);
					}
				}else{
					temptablename=detailtable;
					if(!"".equals(detailid)){
						updateDetailtableSql += ","+fieldName+"=?";
						detailV.addElement(realFieldValue);
					}else{
						updateDetailtableSql += ","+fieldName+"";
						detailV.addElement(realFieldValue);
					}
					if(isdelfile&&fieldHtmlType.equals("6")){
						new DataHelper(user).deleteDocFile(value, modeid, fieldName, detailtable, detailid);
					}
				}
				// CHANGE START
				for (String tempSuffix : suffixList) {
					dataHelper.expandColSize(isfrontmultlang, temptablename + tempSuffix, fieldName, fieldDbType, Util.null2String(realFieldValue), fieldId, fieldType, fieldHtmlType);
				}
				// CHANGE END
			}

			if(mainV.size()>0){
				updateMaintableSql = updateMaintableSql.substring(1);
				// CHANGE START
				updateMaintableSql = "update " + tablename + suffix + " set " + updateMaintableSql + " where id = " + mainid;
				// CHANGE END
				boolean uResult = rs.executeSql(updateMaintableSql,false,mainV);
			}
			String newDetailId="";
			if(detailV.size()>0){
				if(!"".equals(detailid)){
					updateDetailtableSql = updateDetailtableSql.substring(1);
					updateDetailtableSql = "update " + detailtable + suffix + " set " + updateDetailtableSql + " where id = " + detailid;
					rs.executeSql(updateDetailtableSql,false,detailV);
				}else{
					String modeuuid = UUID.randomUUID().toString();
					ModeDataIDUpdateSingle.INSTANCE.addModeUUIDColumnForTable(detailtable);
					updateDetailtableSql = "insert into " + detailtable + suffix + " (mainid" + updateDetailtableSql + ",modeuuid) values (" + mainid;
					for(int k=0;k<detailV.size();k++){
						updateDetailtableSql += ",?";
					}
					updateDetailtableSql += ",'"+modeuuid+"' )";
					rs.executeSql(updateDetailtableSql,false,detailV);

					rs.executeQuery("select id from "+detailtable + suffix +" where modeuuid=?", modeuuid);
					if(rs.next()){
						newDetailId=Util.null2String(rs.getString("id"));
					}
				}
			}
			ModeDataIdUpdate modeDataIdUpdate = new ModeDataIdUpdate();
			RecordSet rSet = new RecordSet();
			if(!VirtualFormHandler.isVirtualForm(formid)){	//如果是虚拟表单，则不需要创建这些字段。
				String modifydatatime = DateHelper.getCurrentDate()+" "+DateHelper.getCurrentTime();
				// CHAGNE START
				for (String tempSuffix : suffixList) {
					modeDataIdUpdate.updateModifyInfo(tablename + tempSuffix);
					if(Util.getIntValue(mainid,-1)>0){
						//更新最后修改人和最后修改时间
						String modifysql = "update "+tablename + tempSuffix +" set modedatamodifier=?,modedatamodifydatetime=? where id=?";
						rSet.executeUpdate(modifysql, user.getUID(),modifydatatime,Util.getIntValue(mainid,-1));
						// 添加置顶逻辑
						int mainid_= Util.getIntValue(mainid,-1);
						SaveConditionUtil.buildTopDataForBatchSave( mainid_,  tablename + tempSuffix,  formid+"", modeid);
					}
				}
				// CHANGE END
			}
    		// CHANGE START
			if(ismodifyneedlogfield){
				customSearchBatchEditUtil.saveLogFieldsModifyInfo(Util.getIntValue(mainid,0),detailid,newDetailId, modeid, user, clientaddress, "5", needLogFieldsMap, formBizId);
			}else{
				ModeViewLog ModeViewLog = new ModeViewLog();
				String operatedesc = SystemEnv.getHtmlLabelName(25465,user.getLanguage());//批量修改
				int htmllabelindex = 25465;//#887673
				String operatetype = "5";
				int operateuserid = user.getUID();
				String relatedname = "";
				ModeViewLog.resetParameter();
				ModeViewLog.setClientaddress(clientaddress);
				ModeViewLog.setModeid(modeid);
				ModeViewLog.setOperatedesc(operatedesc);
				ModeViewLog.setHtmllabelindex(htmllabelindex);
				ModeViewLog.setOperatetype(operatetype);
				ModeViewLog.setOperateuserid(operateuserid);
				ModeViewLog.setRelatedid(Util.getIntValue(mainid,0));
				ModeViewLog.setRelatedname(relatedname);
				ModeViewLog.setFormBizId(formBizId);
				try {
					ModeViewLog.setSysLogInfo();
				}catch(Exception e){

				}

			}
			// CHANGE END


			if(!billList.contains(mainid)){
				billList.add(mainid);
				modeList.add(modeid);
				// CHANGE START
				formBizIdList.add(formBizId);
				// CHANGE END
			}
		}
//      该接口逻辑已废弃，接口旧数据转移到批量修改保存的页面扩展上
//		 判断该查询对应模块是否有 "批量编辑保存接口" 接口,正式系统临时使用方案
//		boolean  isHaveInterface = false;
//		int pageexpandid = 0;
//		rs.executeQuery("select * from   mode_pageexpand  where modeid = ? and (expendname ='批量编辑保存接口' or  (expendname like '%`~`7 批量编辑保存接口`~`%' or expendname  like'%`~`8 批量编辑保存接口`~`%' or  expendname like '%`~`9 批量編輯保存接口`~`%'))",modeid);
//		if(rs.next()){
//			isHaveInterface = true;
//			pageexpandid = rs.getInt("id");
//		}
		//qc647114 需求没定，暂时按同步执行来 批量修改保存按钮
		boolean  isInterface = false;
		int expandid = 0;
		rs.executeQuery("select id from   mode_pageexpand  where modeid =? and issystemflag='99'",modeid);
		if(rs.next()){
			isInterface = true;
			expandid = rs.getInt("id");
		}
		Map<String, String> executeResult= new HashMap<String, String>();
		JSONObject errorDatas = new JSONObject();
		JSONObject errorObj = new JSONObject();
		boolean haveError=false;
		for(int i=0;i<billList.size();i++){
			String bid = billList.get(i);
			int mid = modeList.get(i);
			String formBizId = formBizIdList.get(i);
			int finalModeid = modeid;
			actionThreadPool.submit(new Runnable() {
				@Override
				public void run() {
					ModeRightInfo ModeRightInfo = new ModeRightInfo();
					if (ShardingActionHelper.isModeSharding(finalModeid)) {
					ModeRightInfo.setSuffix(ShardingActionHelper.getShardingSuffix(formBizId));
					}
					ModeRightInfo.rebuildModeDataShareByEdit(-1,mid,Util.getIntValue(bid,0));
					ModeRightInfo.addDocShare(-1,mid,Util.getIntValue(bid,0));
//					RecordSet rs = new RecordSet();
//					String sql = "select id  from modeDataShare_"+mid+" where sourceid="+bid;
//					rs.executeQuery(sql);
//					List<String> ids = new ArrayList<String>(rs.getCounts());
//					while (rs.next()) {
//						String id = Util.null2String(rs.getString("id"));
//						ids.add(id);
//					}
//					ModeRightInfoForList ModeRightInfo = new ModeRightInfoForList();
//					ModeRightInfo.rebuildModeDataShareByEdit(-1,mid,Util.getIntValue(bid,0));
//					ModeRightInfo.addDocShare(-1,mid,Util.getIntValue(bid,0));
//					if (ids.size()>0) {
//						String idstr=StringUtils.join(ids.toArray(),",");
//						sql="delete from modeDataShare_"+mid+" where id in ("+idstr+")";
//						rs.executeUpdate(sql);
//					}
				}
			});
//			if(isHaveInterface){
//				if(Util.getIntValue(bid)<0){
//					continue;
//				}
//				ModeDataInterface modeDataInterface = new ModeDataInterface(Util.getIntValue(bid),modeid);
//				modeDataInterface.setPageexpandid(pageexpandid);
//				modeDataInterface.setUser(user);
//				modeDataInterface.execute();
//			}
			if(isInterface){//批量修改保存按钮执行接口动作
				if(Util.getIntValue(bid)<0){
					continue;
				}
				ModeDataInterface modeDataInterface = new ModeDataInterface(Util.getIntValue(bid),modeid);
				// CHANGE START
				modeDataInterface.setFormBizId(formBizId);
				// CHANGE END
				modeDataInterface.setPageexpandid(expandid);
				modeDataInterface.setUser(user);
				Map<String, Object> params = ParamUtil.request2Map(request);
				modeDataInterface.setParams(params);
				executeResult=modeDataInterface.execute();
			}
			if (executeResult.containsKey("flag")&&executeResult.get("flag").equals("false")) {
				String interfacetypename=executeResult.get("interfacetypename");
				if (errorDatas.containsKey(interfacetypename)) {
					errorDatas.put(interfacetypename, errorDatas.get(interfacetypename)+","+bid);
				}else {
					errorDatas.put(interfacetypename, bid);
				}
				haveError=true;
			}
		}
		if(batchEditMessage.length()==0){
			batchEditMessage.append(SystemEnv.getHtmlLabelName(503113,user.getLanguage()));     //更新成功，是否继续修改？
		}
		//获取当前页面的操作时间
		Calendar today = Calendar.getInstance();
		String formatdate = Util.add0(today.get(Calendar.YEAR), 4) + "-"
				+ Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-"
				+ Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
		String formattime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":"
				+ Util.add0(today.get(Calendar.MINUTE), 2) + ":"
				+ Util.add0(today.get(Calendar.SECOND), 2);
		String time = formatdate+" "+formattime;
		result.put("changeDataTime",time);
		result.put("resultMessage", batchEditMessage.toString());
		result.put("allModifyBillList", allModifyBillList);
		errorObj.put("haveError", haveError);
		errorObj.put("errordata", errorDatas);//批量执行结果
		result.put("pageExpendResult", errorObj);
		return result;
	}
	/***
	 * 获取批量修改数据信息
	 * @param request
	 * @param response
	 * @return
	 */
	public Map<String, Object> getBatchModifyField(HttpServletRequest request,
												   HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();
		RecordSet rs1=new RecordSet();
		int pageexpandid = Util.getIntValue(Util.null2String(request.getParameter("pageexpandid")), 0);

		String id="";
		String formid="";
		String modeid="";
		rs.executeSql("select a.id,a.name,a.remark,a.modeid,a.formid from mode_batchmodify a left join mode_pageexpand b on a.id=b.hrefid where b.id="+pageexpandid);
		if(rs.next()){
			id = Util.null2String(rs.getString("id"));
			modeid = Util.null2String(rs.getString("modeid"));
			formid = Util.null2String(rs.getString("formid"));
		}
		FormModeTransMethod formModeTransMethod=new FormModeTransMethod();
		List<Map<String, Object>> dataList=new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> cells=new ArrayList<Map<String,Object>>();
		Map<String, String> fieldNameMapForLable = new HashMap<String, String>();
		rs.executeSql("select a.feildid,a.feildvalue,a.changetype,b.fieldlabel,b.fielddbtype,b.fieldhtmltype,b.type,b.fieldname,b.qfws from mode_batchmodifydetail a left join workflow_billfield b on a.feildid=b.id where a.MAINID="+id);
		while(rs.next()){
			String feildid=Util.null2String(rs.getString("feildid"));
			String feildvalue=Util.null2String(rs.getString("feildvalue"));
			String defaultvalue = feildvalue;
			String changetype=Util.null2String(rs.getString("changetype"));
			String fieldname=Util.null2String(rs.getString("fieldname"));
			String fieldlabel=Util.null2String(rs.getString("fieldlabel"));
			int qfws=Util.getIntValue(Util.null2String(rs.getString("qfws")), 0);
			if(fieldNameMapForLable.get(fieldname) == null) {
				fieldNameMapForLable.put(fieldname, fieldlabel);
			}

			if("2".equals(changetype)&&fieldNameMapForLable.get(feildvalue.substring(1, feildvalue.length() - 1)) == null) {
				String sql="SELECT fieldlabel FROM workflow_billfield WHERE billid= ? and fieldname=? ";
				RecordSet recordSet=new RecordSet();
				recordSet.executeQuery(sql, formid,feildvalue.substring(1, feildvalue.length() - 1));
				String fieldlabel1="";
				if(recordSet.next()){
					fieldlabel1=Util.null2String(recordSet.getString("fieldlabel"));
				}
				fieldNameMapForLable.put(feildvalue.substring(1, feildvalue.length() - 1), fieldlabel1);
			}
			fieldlabel=SystemEnv.getHtmlLabelName(Util.getIntValue(fieldlabel),user.getLanguage());
			String dbtype=Util.null2String(rs.getString("fielddbtype"));
			String type=Util.null2String(rs.getString("type"));
			String htmltype=Util.null2String(rs.getString("fieldhtmltype"));
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("fieldid", feildid);
			map.put("fieldname", fieldname);
			map.put("fieldlabel", fieldlabel);
			map.put("changetype", changetype);
			map.put("defaultvalue",defaultvalue);
			String feildname="";
			String fieldlableId = "";
			if(changetype.equals("1")){
				String para3=feildvalue+"+"+feildid+"+"+htmltype+"+"+type+"+"+user.getLanguage()
						+"+"+1+"+"+dbtype+"+"+0+"+"+modeid+"+"+formid+"+"+0;
				if(!feildvalue.equals("")&&!feildvalue.equals("NULL")){
					feildname = formModeTransMethod.getOthersSearchname(feildvalue,para3);
				}
				map.put("fieldvalue", feildname);
			}else if(changetype.equals("2")){
				feildname=feildvalue;
				feildname = formModeTransMethod.getDefaultSql(user,"","",feildname);
				map.put("fieldvalue_r", feildname);
				if(!feildvalue.equals("")&&!feildvalue.equals("NULL")&&!(feildname.indexOf("$")>-1)){
					String para3=feildvalue+"+"+feildid+"+"+htmltype+"+"+type+"+"+user.getLanguage()
							+"+"+1+"+"+dbtype+"+"+0+"+"+modeid+"+"+formid+"+"+0;
					feildname = formModeTransMethod.getOthersSearchname(feildname,para3);
				}
				if(feildname.matches("^\\$.+\\$$") && (fieldlableId = fieldNameMapForLable.get(feildname.substring(1, feildname.length() - 1))) != null) {
					if(!Util.null2String(SystemEnv.getHtmlLabelName(Util.getIntValue(fieldlableId, -1), user.getLanguage())).equals("")){
						feildname = "$" + SystemEnv.getHtmlLabelName(Util.getIntValue(fieldlableId, -1), user.getLanguage()) + "$";
					}
				}
				map.put("fieldvalue", feildname);
			}else{
				if(changetype.equals("3")){
					feildvalue="";
				}else if(type.equals("290")){
					feildvalue=new DateTransformer().getLocaleDateTime(feildvalue);
				}
				map.put("fieldvalue", feildvalue);
			}
			dataList.add(map);
			//cells
			Map<String, Object> cellMap=new HashMap<String, Object>();
			List comList=new ArrayList();
			cellMap.put("fieldid", feildid);
			cellMap.put("fieldvalue", BrowserHelper.constructMap("com",comList));
			if("3".equals(changetype)){//用户自定义
				if("1".equals(htmltype)){//单行文本
					if ("3".equals(type)) {
						qfws =  dbtype.indexOf(",") > -1 ? Util.getIntValue(dbtype.substring(dbtype.indexOf(",") + 1, dbtype.indexOf(")"))) : 2;
					}  else if("4".equals(type)) {
						qfws=2;
					}
					if("1".equals(type)){
						comList.add(BrowserHelper.constructMap("type","input","key","fieldvalue","viewAttr","2"));
					}else{
						comList.add(BrowserHelper.constructMap("type","inputnumber","key","fieldvalue","viewAttr","2","precision",qfws));
					}
				}else if("2".equals(htmltype)){//多行文本
					comList.add(BrowserHelper.constructMap("type","textarea","key","fieldvalue","viewAttr","2"));
				}else if("3".equals(htmltype)){//浏览按钮
					if("2".equals(type)){//日期
						comList.add(BrowserHelper.constructMap("type","DATEPICKER","key","fieldvalue","viewAttr","2"));
					}else if("19".equals(type)){//时间
						comList.add(BrowserHelper.constructMap("type","TIMEPICKER","key","fieldvalue","viewAttr","2"));
					}else if("290".equals(type)){//日期时间
						Map<String, Object> otherParams=new HashMap<String, Object>();
						otherParams.put("showTime",true);
						otherParams.put("quickSearch",false);
						otherParams.put("format","yyyy-MM-dd HH:mm");
						comList.add(BrowserHelper.constructMap("type","DATEPICKER","key","fieldvalue","viewAttr","2","otherParams",otherParams));
					}else if("402".equals(type)){
						Map<String, Object> otherParams=new HashMap<String, Object>();
						otherParams.put("noinput",true);
						otherParams.put("quickSearch",false);
						otherParams.put("format","YYYY");
						comList.add(BrowserHelper.constructMap("type","DATEPICKER","key","fieldvalue","viewAttr","2","otherParams",otherParams));
					}else if("403".equals(type)){
						Map<String, Object> otherParams=new HashMap<String, Object>();
						otherParams.put("noinput",true);
						otherParams.put("quickSearch",false);
						otherParams.put("format","YYYY-MM");
						comList.add(BrowserHelper.constructMap("type","DATEPICKER","key","fieldvalue","viewAttr","2","otherParams",otherParams));
					} else{
						BrowserBean browserProps = null;
						if("161".equals(type) || "162".equals(type)){
							browserProps = new BrowserBean(type);
							new BrowserInitUtil().initCustomizeBrow(browserProps,dbtype, Util.getIntValue(type) , user.getUID());
							browserProps.getDataParams().put("formmodefieldid",feildid);
							browserProps.getConditionDataParams().put("formmodefieldid", feildid);
							browserProps.getCompleteParams().put("formmodefieldid", feildid);
						}else if("256".equals(type) || "257".equals(type)){
							browserProps = new BrowserBean(type);
							browserProps.getDataParams().put("cube_treeid", dbtype);
							browserProps.getCompleteParams().put("cube_treeid", dbtype);
							new BrowserInitUtil().initBrowser(browserProps,user.getLanguage());
						}else {
							browserProps = new BrowserBean(type);
							Map<String,Object> mapReplace = new HashMap<>();
							mapReplace.put("fromModule","model");
							mapReplace.put("fieldid",feildid);
							mapReplace.put("modeId",modeid);
							mapReplace.put("isFromMode","1");
							browserProps.setDataParams(mapReplace);
							browserProps.setDestDataParams(mapReplace);
							browserProps.setCompleteParams(mapReplace);
							new BrowserInitUtil().initBrowser(browserProps,user.getLanguage());
						}
						comList.add(BrowserHelper.constructMap("type","BROWSER","key","fieldvalue","viewAttr","2","browserConditionParam",browserProps));
					}
				}else if("4".equals(htmltype)){//Check框
					comList.add(BrowserHelper.constructMap("type","CHECKBOX","key","fieldvalue","viewAttr","2"));
				}else if("5".equals(htmltype)){//选择框
					rs1.executeQuery("select id,selectvalue,selectname from workflow_selectitem where fieldid = ? and cancel!='1' order by listorder,id ", feildid);
					JSONArray options = new JSONArray();
					options.add(BrowserHelper.constructMap("key", "","showname","","selected",true));
					while(rs1.next()) {
						options.add(BrowserHelper.constructMap("key", rs1.getString("selectvalue")
								,"showname", rs1.getString("selectname"),"selected",false));
					}
					comList.add(BrowserHelper.constructMap("type","SELECT","key","fieldvalue","viewAttr","2","options",options,"detailtype",type));
				}else if("6".equals(htmltype)){//附件上传

				}else if("7".equals(htmltype)){//特殊字段

				}
			}else{//变量值,默认值
				comList.add(BrowserHelper.constructMap("type","input","key","fieldvalue","viewAttr","1"));
			}
			cells.add(cellMap);
		}
		result.put("dataList",dataList);
		result.put("cells",cells);
		return result;
	}

	/***
	 * 操作批量修改数据
	 * @param request
	 * @param response
	 * @return
	 */
	public Map<String, Object> saveBatchModifyField(HttpServletRequest request,
													HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);

		String billids = Util.null2String(request.getParameter("billids"));
		String datas = Util.null2String(request.getParameter("datas"));

		int pageexpandid = Util.getIntValue(request.getParameter("pageexpandid"), 0);

		int modeid = 0;
		int formid = 0;
		String tablename="";
		RecordSet rs1 =  new RecordSet();
		rs1.executeQuery("select a.id,a.modeid,a.formid,b.tablename from mode_batchmodify a,workflow_bill b where a.id =(select hrefid from mode_pageexpand where id=? ) and a.formid=b.id", pageexpandid);
		if(rs1.next()){
			modeid=rs1.getInt("modeid");
			formid=rs1.getInt("formid");
			tablename=rs1.getString("tablename");
		}

		if(modeid>0&&pageexpandid>0&&!tablename.isEmpty()){
			ExpandBaseRightInfo rightInfo = new ExpandBaseRightInfo();
			rightInfo.setUser(user);
			//没有页面扩展权限或者 关联的是人力资源表 不允许修改
			if (!rightInfo.checkExpandRight(pageexpandid+"", String.valueOf(modeid))||tablename.equalsIgnoreCase("hrmresource")) {
				// 没有权限，不显示
				result.put("noRight",true);
				return result;
			}
		}else{
			result.put("noRight",true);
			return result;
		}


		RecordSet rs =  new RecordSet();
		String errorCode = "1";
		String error = "";

		//获取表单的记录日志字段
		FormInfoService formInfoService = new FormInfoService();
		List<Map<String, Object>> needlogFieldList = formInfoService.getNeedlogField(formid);
		String tableName = "";
		String columnNames = "";
		if(needlogFieldList.size() > 0){
			for(int i = 0; i < needlogFieldList.size(); i++){
				Map<String, Object> needlogField = needlogFieldList.get(i);
				String fieldname = Util.null2String(needlogField.get("fieldname"));
				String detailtable=Util.null2String(needlogField.get("detailtable"));//qc:935860  批量修改字段值不会修改明细表字段，这里把明细表字段过滤掉
				if(detailtable!=null||!"".equals(detailtable)){
					continue;
				}
				columnNames += fieldname;
				if(i != (needlogFieldList.size() - 1)){
					columnNames += ",";
				}
			}
			rs.executeSql("select tablename from workflow_bill where id = " + formid);
			if (rs.next()){
				tableName = rs.getString("tablename");
			}
		}

		String[] billidsArray = billids.split(",");
		Map<String, Map<String, Object>> oldDataMap = new HashMap();
		for(int i=0;i<billidsArray.length;i++){
			String billid = billidsArray[i];
			Map<String, Object> oldData = new HashMap<String, Object>();
			if(needlogFieldList.size() > 0){
				oldData = formInfoService.getTableData(tableName, Util.getIntValue(billid), columnNames);
			}
			oldDataMap.put(billid, oldData);
		}

		RecordSetTrans rst = new RecordSetTrans();
		FormModeTransMethod formModeTransMethod=new FormModeTransMethod();
		try{
			rst.setAutoCommit(true);
			JSONArray jsonArray=JSONArray.fromObject(datas);
			for(int i=0;i<jsonArray.size();i++){
				JSONObject jsonObject=jsonArray.getJSONObject(i);
				String feildvalue = Util.null2String(jsonObject.get("fieldvalue"));
				String defaultvalue = Util.null2String(jsonObject.get("defaultvalue"));
				String changetype = Util.null2String(jsonObject.get("changetype"));
				if("2".equals(changetype)){
					feildvalue=Util.null2String(jsonObject.get("fieldvalue_r"));
				}
				String fieldname = Util.null2String(jsonObject.get("fieldname"));
				UnifiedConversionInterface uci = new UnifiedConversionInterface();
				if(uci.getTimeZoneStatus()){
					String fieldid = Util.null2String(jsonObject.get("fieldid"));
					rs.execute("select type from workflow_billfield where id="+fieldid );
					if(rs.next()){
						String type = Util.null2String(rs.getString("type"));
						if(type.equals("290")){
							feildvalue="".equals(Util.null2String(feildvalue))?"":new DateTransformer().getServerDateTime(feildvalue);
							defaultvalue="".equals(Util.null2String(defaultvalue))?"":new DateTransformer().getServerDateTime(defaultvalue);
						}
					}
				}
				String sqlwhere="  id in ("+billids+") ";
				String sql = "";
				if(changetype.equals("2")){
					if(feildvalue.contains("$")){
						//处理登录人相关动态参数
						if(feildvalue.contains("$UserId$") || feildvalue.contains("$DepartmentId$") || feildvalue.contains("$AllDepartmentId$")
								|| feildvalue.contains("$SubcompanyId$") || feildvalue.contains("$AllSubcompanyId$")
								|| feildvalue.contains("$date$")){
							feildvalue = formModeTransMethod.getDefaultSql(user,"","",feildvalue);
						}
						//处理字段动态参数
						if(feildvalue.contains("$")){
							String feildvaluename=feildvalue.replaceAll("\\$","");
							String  tempFieldName="";
							Map <String,String> map=new HashMap <String,String>();
							String sqls="select  fieldname,fielddbtype,fieldhtmltype,type from  workflow_billfield  where billid=?  and  fieldname in (?,?)";
							rs.executeQuery(sqls,formid,feildvaluename,fieldname);
							//rs.executeQuery("select    fieldname,fielddbtype,fieldhtmltype,type from  workflow_billfield  where billid="+formid+"   and  fieldname in ( '"+feildvaluename+"','"+fieldname+"')");
							while (rs.next()){
								tempFieldName=rs.getString("fieldname");
								map.put(tempFieldName+"htmltype",rs.getString("fieldhtmltype"));
								map.put(tempFieldName+"type",rs.getString("type"));
							}
							String billidss[] = billids.split(",");
							RecordSet rrss = new RecordSet();
							rrss.isReturnDecryptData(true);
							for(String billid : billidss){
								try{
									String feildvalueNew = feildvalue;
									rrss.executeQuery("select * from "+tablename+" where id = " + billid);
									if (rrss.next()){
										String columnsName[] = rrss.getColumnName();
										for(String columnName1 : columnsName){
											feildvalueNew = feildvalueNew.replaceAll("\\$(?i)"+columnName1.toLowerCase()+"+\\$",Util.null2String(rrss.getString(columnName1.toLowerCase()).replaceAll("\\$", "")));
										}
									}
									//单行文本框字段  ，解决 批量更改字段值 ，金额千分位字段 赋值给  整数、浮点数、金额转换字段 不成功 的问题  QC:723864
									if("1".equals(map.get(fieldname+"htmltype"))&&"1".equals(map.get(feildvaluename+"htmltype"))){
										if(("2".equals(map.get(fieldname+"type"))||"3".equals(map.get(fieldname+"type"))||"4".equals(map.get(fieldname+"type")))&&"5".equals(map.get(feildvaluename+"type"))){
											rst.executeUpdate("update " + tablename + " set " + fieldname + "= ? where id = " + billid, feildvalueNew.replaceAll(",",""));
										}else{
											rst.executeUpdate("update " + tablename + " set " + fieldname + "= ? where id = " + billid, feildvalueNew);
										}
									}else {
										rst.executeUpdate("update " + tablename + " set " + fieldname + "= ? where id = " + billid, feildvalueNew);
									}
								}catch(Exception e){
									writeLog(e);
								}
							}
						}else{
							sql = "update "+tablename+" set "+fieldname+"=? where "+sqlwhere;
							rst.executeUpdate(sql,feildvalue);
						}
					}else{
						sql="update "+tablename+" set "+fieldname+"=? where "+sqlwhere;
						rst.executeUpdate(sql,feildvalue);
					}
				}else{
					if(feildvalue.equals("")){
						rst.executeUpdate("update "+tablename+" set "+fieldname+"=null where "+sqlwhere);
					}else{
						//System.out.println("update "+tablename+" set "+fieldname+"='"+defaultvalue+"' where "+sqlwhere);
						sql = "update "+tablename+" set "+fieldname+"=? where "+sqlwhere;
						if(changetype.equals("1")){
							rst.executeUpdate(sql,defaultvalue);
						}else{
							rst.executeUpdate(sql,feildvalue);
						}

					}
				}
			}
			errorCode="1";
		}catch(Exception e){
			//将错误信息保存到日志中，同时记录一个uuid标识，供前端进行回查
			UUIDPKVFormDataSave uuidpkvFormDataSave = new UUIDPKVFormDataSave();
			String uuid = uuidpkvFormDataSave.generateID(null).toString();
			BaseBean baseBean = new BaseBean();
			baseBean.writeLog("errorFlag:" + uuid);
			baseBean.writeLog(e);
			rst.rollback();
			errorCode="-1";
			error=SystemEnv.getHtmlLabelName(507940,user.getLanguage()) + "uuid:" + uuid;
		}

		//记录更新日志
		if(errorCode.equals("1")) {
			//更新最后修改人和修改时间
			ModeDataIdUpdate modeDataIdUpdate = new ModeDataIdUpdate();
			RecordSet rSet = new RecordSet();
			if(!VirtualFormHandler.isVirtualForm(formid)){	//如果是虚拟表单，则不需要创建这些字段。
				modeDataIdUpdate.updateModifyInfo(tablename);

			}
			Set<String> keys = oldDataMap.keySet();
			for(String key : keys) {
				if(Util.getIntValue(key)>0){
					//更新最后修改人和最后修改时间
					String modifydatatime = DateHelper.getCurrentDate()+" "+DateHelper.getCurrentTime();
					String sql = "update "+tablename+" set modedatamodifier=?,modedatamodifydatetime=? where id=?";
					rSet.executeUpdate(sql, user.getUID(),modifydatatime,Util.getIntValue(key));
				}
				ModeViewLog ModeViewLog = new ModeViewLog();
				String operatedesc = SystemEnv.getHtmlLabelName(503114, user.getLanguage());//修改（批量修改）
				int htmllabelindex = 503114;//#887673
				String operatetype = "2";//操作的类型： 1：新建 2：修改 3：删除 4：查看
				String relatedname = "";
				ModeViewLog.resetParameter();
				ModeViewLog.setClientaddress(request.getRemoteAddr());
				ModeViewLog.setModeid(modeid);
				ModeViewLog.setOperatedesc(operatedesc);
				ModeViewLog.setHtmllabelindex(htmllabelindex);
				ModeViewLog.setOperatetype(operatetype);
				ModeViewLog.setOperateuserid(user.getUID());
				ModeViewLog.setRelatedid(Util.getIntValue(key));
				ModeViewLog.setRelatedname(relatedname);
				long viewlogid=0;
				try {
					viewlogid = ModeViewLog.setSysLogInfo();
				} catch (Exception e) {
					e.printStackTrace();
				}
				Map<String, Object> nowData = new HashMap<String, Object>();
				Map<String, Object> oldData = oldDataMap.get(key);
				if(needlogFieldList.size() > 0){
					nowData = formInfoService.getTableData(tableName, Util.getIntValue(key), columnNames);
				}
				if(operatetype.equals("2")&&needlogFieldList!=null){
					if(needlogFieldList.size() > 0){
						for(int i = 0; i < needlogFieldList.size(); i++){
							Map<String, Object> needlogField = needlogFieldList.get(i);
							String fieldid = Util.null2String(needlogField.get("id"));
							String fieldname = Util.null2String(needlogField.get("fieldname"));
							String detailtable = Util.null2String(needlogField.get("detailtable"));
							if(!"".equals(detailtable)){//批量修改不会修改明细表字段，也就不会有日志，跳过明细表字段
								continue;
							}
							String oldFieldValue = Util.null2String(oldData.get(fieldname));
							String nowFieldValue = Util.null2String(nowData.get(fieldname));
							if(!oldFieldValue.equals(nowFieldValue)){
								Map<String, Object> logDetailMap = new HashMap<String,	Object>();
								logDetailMap.put("viewlogid", viewlogid);
								logDetailMap.put("fieldid", fieldid);
								logDetailMap.put("fieldvalue", nowFieldValue);
								logDetailMap.put("prefieldvalue", oldFieldValue);
								logDetailMap.put("modeid", modeid);
								formInfoService.saveFieldLogDetail(logDetailMap);
							}
						}
					}
				}
			}
		}

		ModeDataManager ModeDataManager=new ModeDataManager();
		ModeDataManager.setFormid(formid);
		ModeDataManager.setFormmodeid(modeid);
		ModeDataManager.setPageexpandid(pageexpandid);
		ModeDataManager.setUser(user);
		Map<String, String> executeResult= new HashMap<String, String>();
		JSONObject errorDatas = new JSONObject();
		JSONObject errorObj = new JSONObject();
		boolean haveError=false;
		for(int i=0;i<billidsArray.length;i++){//重构主表字段权限和角色权限
			int sourceId = Util.getIntValue(billidsArray[i]);
			if(sourceId==-1){
				continue;
			}
			ModeRightInfo ModeRightInfo = new ModeRightInfo();
			ModeRightInfo.rebuildModeDataShareByEdit(-1,modeid,sourceId);
			ModeRightInfo.addDocShare(-1,modeid,sourceId);
			ModeDataManager.setBillid(sourceId);
			executeResult=ModeDataManager.doInterface(pageexpandid);
			if (executeResult.containsKey("flag")&&executeResult.get("flag").equals("false")) {
				String interfacetypename=executeResult.get("interfacetypename");
				if (errorDatas.containsKey(interfacetypename)) {
					errorDatas.put(interfacetypename, errorDatas.get(interfacetypename)+","+sourceId);
				}else {
					errorDatas.put(interfacetypename, sourceId);
				}
				haveError=true;
			}
		}
		errorObj.put("haveError", haveError);
		errorObj.put("errordata", errorDatas);//批量执行结果
		result.put("pageExpendResult", errorObj);
		result.put("errorCode", errorCode);
		result.put("error", error);
		return result;
	}


	/***
	 * 校验数据是否过期
	 * @param request
	 * @param response
	 * @return
	 */
	public Map<String, Object> checkDataIsChange(HttpServletRequest request,
												 HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();
		CustomSearchComInfo customSearchComInfo = new CustomSearchComInfo();
		int customid = Util.getIntValue(Util.null2String(request.getParameter("customid")), 0);
		String oldData = Util.null2String(request.getParameter("oldData"));
		JSONArray oldDataArray=JSONArray.fromObject(oldData);
		int modeId = Util.getIntValue(customSearchComInfo.getModeId(""+customid));
		String rowNum ="";
		String errMessage ="";
		JSONArray datas = new JSONArray();
		// CHANGE START
		boolean isModeSharding = ShardingActionHelper.isModeSharding(modeId);
		String relatedkey = ShardingActionHelper.getRelatedKey(modeId);
		// CHANGE END
		try {
			for (int i = 0; i <oldDataArray.size() ; i++) {
				boolean dataIsChange = false;
				JSONObject jsonObject = oldDataArray.getJSONObject(i);
				String mainid = Util.null2o(jsonObject.getString("randomFieldId"));
				int row = Util.getIntValue(jsonObject.getString("row"),0)+1;
				// CHANGE START
				rs.executeQuery("select t1.* from  ModeViewLog_"+modeId+ " t1    where  t1."+ relatedkey +"=? and t1.operatetype in (2,3,5) order by id desc ",mainid);
				// CHANGE END
				String operatedate ="";
				String operatetime ="";
				if(rs.next()){
					operatedate = rs.getString("operatedate");
					operatetime = rs.getString("operatetime");
				}
				String lodDate =  Util.null2o(jsonObject.getString("time"));
				String dateString = operatedate+" "+operatetime;
				rs.writeLog("id:"+mainid+"   lodDate:"+lodDate+"   dateString:"+dateString);
				if(!"".equals(dateString)&&!lodDate.equals("0")&&lodDate.compareTo(dateString)<0){//数据的加载时间小于修改时间(modeviewlog_xx表写日志可能耗时较长，导致数据加载时间小于修改时间，其实应该是等于关系，增加操作人判断)
					dataIsChange = true;
				}
				if(dataIsChange){
					if (rowNum.equals("")) {
						rowNum += row;
					} else {
						rowNum += "," +row;
					}
					datas.add(jsonObject);
				}

			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		if(!"".equals(rowNum)){
			errMessage =SystemEnv.getHtmlLabelName(508321,user.getLanguage())+rowNum+SystemEnv.getHtmlLabelName(508322,user.getLanguage());
		}
		result.put("errMessage", errMessage);
		result.put("datas",datas);
		return result;
	}
	/***
	 * 批量修改保存接口 验证数据是否修改
	 * @param request
	 * @param response
	 * @return
	 */
	public Map<String, Object> checkDataChange(HttpServletRequest request,
											   HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		User user = HrmUserVarify.getUser(request,response);
		RecordSet rs =  new RecordSet();
		CustomSearchComInfo customSearchComInfo = new CustomSearchComInfo();
		int customid = Util.getIntValue(Util.null2String(request.getParameter("customid")), 0);
		String oldData = Util.null2String(request.getParameter("oldData"));
		JSONArray oldDataArray=JSONArray.fromObject(oldData);
		int modeId = Util.getIntValue(customSearchComInfo.getModeId(""+customid));
		String rowNum ="";
		String errMessage ="";
		int isSize = 0;
		boolean isAllData = true;
		JSONArray datas = new JSONArray();
		// CHANGE START
		boolean isModeSharding = ShardingActionHelper.isModeSharding(modeId);
		String relatedkey = ShardingActionHelper.getRelatedKey(modeId);
		// CHANGE END
		try {
			for (int i = 0; i <oldDataArray.size() ; i++) {
				boolean dataIsChange = false;
				JSONObject jsonObject = oldDataArray.getJSONObject(i);
				String mainid = Util.null2o(jsonObject.getString("randomFieldId"));
				// CHANGE START
				rs.executeQuery("select t1.* from  ModeViewLog_"+modeId+ " t1    where  t1."+ relatedkey +"="+mainid+" and t1.operatetype in (2,3,5) order by id desc ");
				// CHANGE END
				String operatedate ="";
				String operatetime ="";
				if(rs.next()){
					operatedate = rs.getString("operatedate");
					operatetime = rs.getString("operatetime");
				}
				String lodDate =  Util.null2o(jsonObject.getString("changeDataTime"));
				String dateString = operatedate+" "+operatetime;
				if(!"".equals(dateString)&&!lodDate.equals("0")&&lodDate.compareTo(dateString)<0){//数据的加载时间小于修改时间(modeviewlog_xx表写日志可能耗时较长，导致数据加载时间小于修改时间，其实应该是等于关系，增加操作人判断)
					dataIsChange = true;
				}
				if(dataIsChange){
					if (rowNum.equals("")) {
						rowNum += mainid;
					} else {
						rowNum += "," +mainid;
					}
					datas.add(jsonObject);
					isSize++;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		if(isSize != oldDataArray.size()&&!rowNum.equals("")){
			errMessage =SystemEnv.getHtmlLabelName(508324,user.getLanguage())+rowNum+SystemEnv.getHtmlLabelName(508325,user.getLanguage());
		}else if(isSize == oldDataArray.size()){
			errMessage =SystemEnv.getHtmlLabelName(508326,user.getLanguage());
			isAllData = false;
		}
		result.put("isAllData", isAllData);
		result.put("errMessage", errMessage);
		result.put("datas",datas);
		return result;
	}

}
